package com.sheng.controller;

import com.sheng.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UserController {

    @Autowired
    @Qualifier("userServiceImpl")
    public UserService userService;

    @PostMapping("/login")
    public String login(@RequestParam("username") String username,@RequestParam("password") String password , Model model){
        if(userService.login(username,password)){
            model.addAttribute("tip","登录成功");
            return "success";
        }
        model.addAttribute("tip","登录失败");
        return "error";
    }

}
